﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ServBus.ListForm2010.License
{
    public enum FeatureSet
    {
        Lite,
        Standard,
        Professional,
        Enterprise
    }

    public enum LicenseType
    {
        Normal,
        Trail,
        Beta
    }

    [Serializable]
    public class License
    {
        public string ProductName { get; private set; }
        public FeatureSet FeatureSet { get; private set; }
        public LicenseType LicenseType { get; private set; }
        public int ActivationLimit { get; private set; }
        public DateTime IssuedDate { get; private set; }
        public DateTime ExpirationDate { get; private set; }
        public string Company { get; private set; }
        public string IssuedTo { get; private set; }
        public string IssuedBy { get; private set; }
        public string LicenseKey { get; private set; }
        public string InfoJetKey { get; private set; }
        private List<Guid> _serverInfos;

        public License(string productName, FeatureSet featureSet, LicenseType licenseType, int activationLimit,
            DateTime issuedDate, DateTime expirationDate, string company, string issuedTo, string issuedBy,
            string licenseKey, string infoJetKey, IEnumerable<Guid> _serverIds)
        {
            this.ProductName = productName;
            this.FeatureSet = featureSet;
            this.LicenseType = licenseType;
            this.ActivationLimit = activationLimit;
            this.IssuedDate = issuedDate;
            this.ExpirationDate = expirationDate;
            this.Company = company;
            this.IssuedTo = issuedTo;
            this.IssuedBy = issuedBy;
            this.LicenseKey = licenseKey;
            this.InfoJetKey = infoJetKey;
            this._serverInfos = new List<Guid>(_serverIds);
        }

        public bool IsValidServer(Guid serverId)
        {
            if (this.LicenseType == LicenseType.Normal)
                return this._serverInfos.Contains(serverId);
            else
                return true;
        }
    }
}
